<?php 
	class Statistics_model extends CI_Model{

	 	function __construct(){
        	parent::__construct();
    	}

    	function school_sttistics($school_id){
    		$where = '';
    		$class_where = '';
    		if($this->is_manage != 1){
    			$where = " AND teacher_id = '{$this->user_data['teacher_id']}'";
    			$class_where = " AND manage_teacher_id = '{$this->user_data['teacher_id']}'";
    		}
    		$sql = "SELECT 
						(select count(0) from edu_course where school_id =$school_id and type = 1 $where) AS shipinke,
						(select count(0) from edu_course where school_id =$school_id and type = 2 $where) AS zhiboke,
						(select count(0) from edu_course where school_id =$school_id and type = 3 $where) AS banke,
						(select count(0) from edu_video where school_id =$school_id $where) AS shipin,
						(select count(0) from edu_user where is_teacher = 0 AND school_id =$school_id ) AS member,
						(select count(0) from edu_user where is_teacher = 0 AND school_id =$school_id and is_vip =1) AS vip,
						(select count(0) from edu_o2o_school_student where school_id =$school_id ) AS student,
						(select count(0) from edu_o2o_class where school_id =$school_id $class_where) AS classes
						";
			return $this->db->query($sql)->row_array();
    	}


    }